﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace RealEstateCenter
{
    public partial class ShowEstate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Session["edit_agency_id"] = Request.QueryString["id"];
                string connectionString;
                SqlConnection sqlconnect;
                connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|RealEstateCenter.mdf;Integrated Security=True;User Instance=True";
                sqlconnect = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand("select * from Estate where estate_id='" + Request.QueryString["id"] + "'", sqlconnect);
                sqlconnect.Open();
                SqlDataReader dtrReader = cmd.ExecuteReader();
                Image estatepic = new Image();
                if (dtrReader.Read())
                {
                    estate_address.Text = dtrReader["estate_address"].ToString();
                    estate_city.Text = dtrReader["estate_city"].ToString();
                    estate_room_number.Text = dtrReader["estate_room_number"].ToString();
                    estate_description.Text = dtrReader["estate_description"].ToString();
                    estate_price.Text = dtrReader["estate_price"].ToString();
                    estate_heating_type.Text = dtrReader["estate_heating_type"].ToString();
                    estate_type.Text = dtrReader["estate_type"].ToString();
                    estate_floor.Text = dtrReader["estate_floor"].ToString();
                    estate_agency_id.Text = dtrReader["estate_agency_id"].ToString();
                    estate_pic.ImageUrl = "ShowImage.aspx?id=" + Request.QueryString["id"];
                }
            }
        }
    }
}